﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DeviceInfoManage.BusinessLogicLayer;

public partial class FileTypeManage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["adminUserName"] == null)
            {
                Response.Redirect("login.aspx");
            }
        }
    }
    protected void Btn_Add_Click(object sender, EventArgs e)
    {
        /*添加新的设备类别*/
        string FileTypeName = this.txtFileTypeName.Text;
        if (string.IsNullOrEmpty(FileTypeName))
        {
            Response.Write("<script>alert('文件类别名称信息不能为空!');location.href=location.href;</script>");
        }
        else
        {
            FileType fileType = new FileType();
            if (fileType.AddFileType(FileTypeName))
                Response.Write("<script>alert('文件新类别信息添加成功!');location.href='FileTypeManage.aspx';</script>");
            else
                Response.Write("<script>alert('" + fileType.ErrMessage + "');</script>");
        }
    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            //当鼠标选择某行时变颜色
            e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#00ffee';");
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
            //Literal operation = (Literal)(e.Row.Cells[2].FindControl("operation"));
            //string fileTypeId = e.Row.Cells[0].Text;
            //operation.Text = "<a href='FileTypeEdit.aspx?fileTypeId=" + fileTypeId + "'><img src='images/edit.gif' height=14 width=14 border=0>修改</a>&nbsp;&nbsp;<a href='FileTypeDel.aspx?fileTypeId=" + fileTypeId + "'><img src='images/delete.gif' width=14 height=14 border=0>删除</a>";
        }
    }
}
